package com.azzaou.dao;

import java.util.HashMap;
import java.util.List;

import org.hibernate.Session;

public interface IDAO<E>
{
  /**
   * get the current session of hibernate
   * 
   * @return objet session
   */
  public Session getCurrentSession();

  /**
   * get the class Name of object
   * 
   * @return name of the class
   */
  public abstract String getPojoClassName();

  /**
   * Method to persist Object in DB
   * 
   * @param transientInstance
   *          : object to persist
   */
  public void persist(E transientInstance);

  /**
   * Method to saveOrUpdate
   * 
   * @param instance
   *          : object to saveOrUpdate
   */
  public void saveOrUpdate(E instance);

  /**
   * Method to Update
   * 
   * @param instance
   *          : object to Update
   */
  public void update(E instance);

  /**
   * Method to merge
   * 
   * @param instance
   *          : object to merge
   */
  public void merge(E instance);

  /**
   * Method to delete object in DB
   * 
   * @param persistentInstance
   *          : object to delete
   */
  public void delete(E persistentInstance);

  /**
   * Method to execute hql query
   * 
   * @param hqlQuery
   *          : query hql to execute
   * @param map
   *          : parameters
   * @return List<E> : result list
   * @throws RuntimeException
   *           : RuntimeException
   */
  public List<E> executerRequeteHql(String hqlQuery, HashMap map)
      throws RuntimeException;

  /**
   * Method to execute hql query
   * 
   * @param hqlQuery
   *          : query hql to execute
   * @param map
   *          : parameters
   * @param maxResult
   *          :number of result to get
   * @return List<E> : result list
   */
  public List<E> executerRequeteHql(String hqlQuery, 
      HashMap map, Long maxResult);

  /**
   * Method to update
   * 
   * @param queryUpdate : query to update
   * @param map
   *          : parameters
   * @return int : status of update
   */
  public int executerRequeteUpdate(String queryUpdate, HashMap map);

  /**
   * Method to find by ID
   * 
   * @param id
   *          : id to search
   * @return result
   * @throws RuntimeException
   *           :RuntimeException
   */
  public E findById(Long id) throws RuntimeException;

  /**
   * Method to get allinstance
   * 
   * @return List<E>: list result
   */
  public List<E> getAllInstances();

}
